//
//  SetViewController.m
//  HuiYinMaster
//
//  Created by Icloud-Zhanyong on 2017/4/14.
//  Copyright © 2017年 Rowling. All rights reserved.
//

#import "SetViewController.h"
#import "SetTableViewCell.h"
#import "AdviceViewController.h"
#import "AboutViewController.h"

@interface SetViewController ()

@end

@implementation SetViewController

- (void)viewDidLoad {
    UITableView * tableView = [[UITableView alloc]initWithFrame:CGRectMake(0, 0, self.view.bounds.size.width, SCREEN_HEIGHT / 13 * 6) style:UITableViewStylePlain];
    [super viewDidLoad];
    [self CreatUI];
    tableView.delegate = self;
    tableView.dataSource = self;
    tableView.scrollEnabled = false;
    [self.view addSubview:tableView];
}

- (void)CreatUI{
    [self.navigationController setNavigationBarHidden:false animated:true];
    self.title = @"设置";
}

-(NSInteger)numberOfSectionsInTableView:(UITableView *)tableView {
    return 2;
}

-(NSInteger)tableView:(UITableView *)tableView numberOfRowsInSection:(NSInteger)section{
    return section == 0 ? 4 : 2;
}

-(UITableViewCell *)tableView:(UITableView *)tableView cellForRowAtIndexPath:(NSIndexPath *)indexPath{
    SetTableViewCell * cell = [SetTableViewCell CellWith:tableView];
    if (indexPath.section == 1) {
        if (indexPath.row == 0) {
            cell.setLeftLabel.text = @"意见反馈";
            cell.accessoryType = UITableViewCellAccessoryDisclosureIndicator;
        }else {
            cell.setLeftLabel.text = @"关于";
            cell.accessoryType = UITableViewCellAccessoryDisclosureIndicator;
        }
        return cell;
    }
    switch (indexPath.row) {
        case 0:{
            cell.setLeftLabel.text = @"断点续听";
            UISwitch *swith1 =  [[UISwitch alloc]initWithFrame:CGRectMake(SCREEN_WIDTH - 31 - SCREEN_WIDTH / 10, (SCREEN_HEIGHT/13 - 31) / 2, 10, 10)];
            swith1.on = YES;
            [self.view addSubview:swith1];
        }
            break;
        case 1:{
            cell.setLeftLabel.text = @"2G/3G/4G 播放和下载";
            UISwitch *swith1 =  [[UISwitch alloc]initWithFrame:CGRectMake(SCREEN_WIDTH - 31 - SCREEN_WIDTH / 10, (SCREEN_HEIGHT/13 - 31) / 2 + SCREEN_HEIGHT / 13, 10, 10)];
            [self.view addSubview:swith1];
        }
            break;
        case 2:{
            cell.setLeftLabel.text = @"推送设置";
            UISwitch *swith1 =  [[UISwitch alloc]initWithFrame:CGRectMake(SCREEN_WIDTH - 31 - SCREEN_WIDTH / 10, (SCREEN_HEIGHT/13 - 31) / 2 + SCREEN_HEIGHT / 13 * 2, 10, 10)];
            swith1.on = YES;
            [self.view addSubview:swith1];
        }
            break;
        case 3:{
            cell.setLeftLabel.text = @"清理占用空间";
            cell.accessoryType = UITableViewCellAccessoryDisclosureIndicator;
            UILabel *label = [[UILabel alloc]initWithFrame:CGRectMake(SCREEN_WIDTH - 31 - SCREEN_WIDTH / 10, SCREEN_HEIGHT / 13 * 3 + (SCREEN_HEIGHT / 13 - 20) / 2, 40, 20)];
            label.text = @"66.6M";
            label.font = [UIFont systemFontOfSize: 12];
            [self.view addSubview:label];
        }
            break;
        default:
            break;
    }
    return  cell;
}
-(void)tableView:(UITableView *)tableView didSelectRowAtIndexPath:(NSIndexPath *)indexPath{
    if (indexPath.section == 1){
        switch (indexPath.row) {
            case 0:
            {
                AdviceViewController * vc = [[AdviceViewController alloc]init];
                [self.navigationController pushViewController:vc animated:YES];
            }
                break;
            case 1:
            {
                AboutViewController * vc = [[AboutViewController alloc]init];
                [self.navigationController pushViewController:vc animated:YES];
            }
                break;
            default:
                break;
        }
    }
}

-(CGFloat)tableView:(UITableView *)tableView heightForHeaderInSection:(NSInteger)section {
    return  section == 0 ? 0 : 10;
}
-(CGFloat)tableView:(UITableView *)tableView heightForRowAtIndexPath:(NSIndexPath *)indexPath{
    return SCREEN_HEIGHT / 13;
}
//-(NSInteger)tableView:(UITableView *)tableView numberOfRowsInSection:(NSInteger)section{
//    return 6;
//}
@end
